import { defineStore } from "pinia";
import { store } from "@/store";
import { isDarkMode, updateDarkMode } from "@/utils/dark-mode";

export const useDarkModeStore = defineStore({
  id: "dark-mode",
  state: () => ({
    darkMode: isDarkMode()
  }),
  actions: {
    toggleDarkMode() {
      // 完全简化的切换逻辑
      this.darkMode = !this.darkMode;
      updateDarkMode(this.darkMode);
    }
  }
});

export function useDarkModeStoreHook() {
  return useDarkModeStore(store);
}
